<?php
class notesModel extends appModel{
    
    protected function init(){
        
    } 

    public function notes(){       
        $data = array();
        
        $start = isset($_GET['start']) ? $_GET['start'] : 0;
        $limit = isset($_GET['limit']) ? $_GET['limit'] : 10;

        $query = "SELECT * FROM `notes` ORDER BY `name` LIMIT {$start},{$limit}";

        $result = $this->db->query($query);
        
        $nbrows = $this->db->fetchRow($this->db->query("SELECT COUNT(*) FROM `course_fields`"));
        $nbrows = $nbrows[0];
        while($row=$this->db->fetchAssoc($result)){
            $data[]=$row;
        }
// print_r($data);
        if(MyHelpers::isAjax()){
            // prepare the metadata
            $ret['metaData'] =   $this->makeMetaData($result);
            $ret['total']    =   $nbrows;
            $ret['data']     =   $this->Char2Utf8($data);
            $ret['success']  =   true;
            $ret['message']  =   true;
            return json_encode($ret);
        }


        return $data;       
    }
    public function notesfeilds($id,$name,$title,$descp,$point_num,$files){
        $id = false;
        
        $result = $this->db->query("INSERT INTO notes (name, title, descp, point_num,files) VALUES ('$name', '$title', '$descp', '$point_num', '$files')");
        if($result != false){
            $id = $this->db->insertId();
        }

        return $id;
    }
     
}
?>